	// EMPLOYMENT VARIABLES

foreach p in b e {

	foreach x in contract shop table buysell pettytrade trade office carload carwash moto carryload guard houseclswp scavenge beg farm drugsell stealing gambling smallbiz constr fish goldrubber other {


				gen `x'4whrs_zero_`p'=`x'4whrstot_`p'
				replace `x'4whrs_zero_`p'=0 if `x'4whrs_zero_`p'==.


				gen `x'7da_zero_`p'=`x'4whrs_zero_`p'/4

				replace `x'7da_zero_`p'=80 if `x'7da_zero_`p'>80

				la var `x'7da_zero_`p' "`x': Average weekly hours"

				}

			}


	foreach p in b e {

			egen total7da_zero_`p' = rowtotal(contract7da_zero_`p' shop7da_zero_`p' table7da_zero_`p' buysell7da_zero_`p' pettytrade7da_zero_`p' trade7da_zero_`p' office7da_zero_`p' carload7da_zero_`p' carwash7da_zero_`p' moto7da_zero_`p' carryload7da_zero_`p' guard7da_zero_`p' houseclswp7da_zero_`p' scavenge7da_zero_`p' beg7da_zero_`p' farm7da_zero_`p' drugsell7da_zero_`p' stealing7da_zero_`p' gambling7da_zero_`p' smallbiz7da_zero_`p' constr7da_zero_`p' fish7da_zero_`p' goldrubber7da_zero_`p' other7da_zero_`p'), m
				la var total7da_zero_`p' "Average weekly work hours"

			egen illicit7da_zero_`p' = rowtotal(drugsell7da_zero_`p'	stealing7da_zero_`p'	gambling7da_zero_`p'	goldrubber7da_zero_`p'	scavenge7da_zero_`p'	beg7da_zero_`p'), m
				la var illicit7da_zero_`p' "Average weekly illicit work hours"

			egen agricul7da_zero_`p' = rowtotal(farm7da_zero_`p' fish7da_zero_`p'), m
				la var agricul7da_zero_`p' "Average weekly agricultural work hours"

			egen nonagwage7da_zero_`p' = rowtotal(contract7da_zero_`p' carload7da_zero_`p' carwash7da_zero_`p'	moto7da_zero_`p'	carryload7da_zero_`p'	constr7da_zero_`p'	guard7da_zero_`p'	houseclswp7da_zero_`p'	other7da_zero_`p'), m
				la var nonagwage7da_zero_`p' "Average weekly hours, non-agricultural low-skill wage labor"

			egen nonagbiz7da_zero_`p' = rowtotal(shop7da_zero_`p'	table7da_zero_`p'	buysell7da_zero_`p'	pettytrade7da_zero_`p'	smallbiz7da_zero_`p'), m
				la var nonagbiz7da_zero_`p' "Average weekly hours, non-agricultural low-skill business"

			egen nonaghigh7da_zero_`p' = rowtotal(trade7da_zero_`p'	office7da_zero_`p'), m
				la var nonaghigh7da_zero_`p' "Average weekly hours, non-agricultural high-skill work"

			egen allbiz7da_zero_`p' = rowtotal(nonagbiz7da_zero_`p' agricul7da_zero_`p'), m
				la var allbiz7da_zero_`p' "All weekly hours, business for self"

			}

	// Work Experience By Category
	egen agriculeveramt_b = rowtotal(farmeveramt_b)
		la var agriculeveramt_b "Years of experience in agricultural"
	egen nonagbizeveramt_b = rowtotal(shopeveramt_b tableeveramt_b buyselleveramt_b pettytradeeveramt_b)
		la var nonagbizeveramt_b "Years of experience in non-agricultural low-skill business"
	egen nonaghigheveramt_b = rowtotal(tradeeveramt_b	officeeveramt_b)
		la var nonaghigheveramt_b "Years of experience in non-agricultural high-skill work"
	egen allbizeveramt_b = rowtotal(nonagbizeveramt_b agriculeveramt_b)
		la var allbizeveramt_b "Years of experience in business for self"




		* Occupational choice construction
		* Create average for each outcome variable
		local cond "if (p1_e5m==1 | p2_e2wks ==1 | p2_e2w2w ==1| p1_e7m==1 | p1_e12m==1 | p1_e13m==1 | p3_e2w==1 | p3_e5w==1 | p2_e12m ==1 | p2_e13m ==1 | p3_e12m ==1 | p3_e13m ==1 | p1_e9y==1 | p2_e9y==1 | p3_e9y==1  | p1_e10y==1 | p2_e10y==1 | p3_e10y==1)"

		foreach x in contract shop table buysell pettytrade trade office carload carwash moto carryload guard houseclswp scavenge beg farm drugsell stealing gambling smallbiz constr fish goldrubber other {
			egen `x'7dhrtotb_e = rowmean(`x'7dhrstot_e `x'prev7dhrstot_e)
			}

		egen nonaghighhouravg7d_e = rowtotal(trade7dhrtotb_e office7dhrtotb_e) `cond' ,m

		egen nonagbizhouravg7d_e = rowtotal(shop7dhrtotb_e table7dhrtotb_e buysell7dhrtotb_e pettytrade7dhrtotb_e ///
											smallbiz7dhrtotb_e) `cond',m

		egen nonagwagehouravg7d_e = rowtotal(contract7dhrtotb_e  carload7dhrtotb_e carwash7dhrtotb_e ///
											 moto7dhrtotb_e carryload7dhrtotb_e guard7dhrtotb_e houseclswp7dhrtotb_e ///
											 constr7dhrtotb_e other7dhrtotb_e) `cond',m

		egen agriculhouravg7d_e = rowtotal(farm7dhrtotb_e fish7dhrtotb_e) `cond',m

		egen illicithouravg7d_e = rowtotal(scavenge7dhrtotb_e beg7dhrtotb_e drugsell7dhrtotb_e ///
											stealing7dhrtotb_e gambling7dhrtotb_e ///
											goldrubber7dhrtotb_e) `cond',m

		egen totalhouravg7d_e = rowtotal(illicithouravg7d_e agriculhouravg7d_e ///
										nonagwagehouravg7d_e nonagbizhouravg7d_e nonaghighhouravg7d_e) `cond',m

		foreach x in houravg7d_e nonaghighhouravg7d_e nonagbizhouravg7d_e nonagwagehouravg7d_e agriculhouravg7d_e illicithouravg7d_e {
			replace `x' = 126 if `x' >= 126 & `x' != .
		}
